{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1e07826a-4e11-445c-a23d-67793e9852c3",
   "metadata": {},
   "source": [
    "## 0. 执行前说明\n",
    "- 需要修改的参数\n",
    "    - root：sar_aircraft项目原始数据的根目录，和current_path(也就是代码所在路径)是同级的\n",
    "    - yolo_datasets_path ：yolo对应数据集的路径\n",
    "- 原始数据目录结构\n",
    "    - 目录结构：\n",
    "            - current_path\n",
    "            - sar_aircraft\n",
    "                - JPEGImages\n",
    "                - Annotations\n",
    "      注：原始数据需要解压"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "73757ffa-3119-45aa-9fda-b03b13f66beb",
   "metadata": {},
   "source": [
    "## 1. 读取分类文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0badd845-4f04-4fb2-b42a-c7130b3e262a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import random\n",
    "import shutil # 处理文件和目录\n",
    "from xml.etree import ElementTree\n",
    "from sklearn.model_selection import train_test_split\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "02528fec-c90f-41a9-b766-3470a1295cd8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(16463, 2)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv(filepath_or_buffer=\"output.csv\")\n",
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a7dab09-57ed-4002-a01c-a5d856a71e13",
   "metadata": {},
   "source": [
    "## 2. 定义字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8203e1a1-a111-493f-b40a-29592bb9e848",
   "metadata": {},
   "outputs": [],
   "source": [
    "label2idx = {\"A330\": 0, \n",
    "             \"A320/321\": 1, \n",
    "             \"A220\": 2, \n",
    "             \"ARJ21\":3, \n",
    "             \"Boeing737\": 4, \n",
    "             \"Boeing787\":5, \n",
    "             \"other\":6}\n",
    "# 反向标签\n",
    "idx2label = {idx: label for label, idx in label2idx.items()}"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c49dd79b-263a-481a-83b2-b6266200bcc9",
   "metadata": {},
   "source": [
    "## 3. 划分A330类的数据集"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34f54aba-e98a-44d2-a3e8-58fd22da6165",
   "metadata": {},
   "source": [
    "思路：\n",
    "- 找出所有包含A330的图像作为正样本， 并随机找出相同数量的不包含A330的图像做负样本\n",
    "- 分为train（75%），val（20%）， test（5%）\n",
    "- test做最终验证，做为考题"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "37405f8b-d63a-491c-98f4-9c0ab56022f0",
   "metadata": {},
   "source": [
    "### 3.1 建立A330二分类的目录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "938ebac3-dd8d-49a5-beec-3c774823fa41",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 原始数据的目录\n",
    "current_path = os.getcwd()\n",
    "root = os.path.join(current_path, \"sar_aircraft_source\")\n",
    "root_images_path = os.path.join(root, \"JPEGImages\")\n",
    "root_labels_path = os.path.join(root, \"Annotations\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "02be5272-4d49-4cdf-8f3f-b62070a4a79a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "项目目录已重新创建\n"
     ]
    }
   ],
   "source": [
    "# 数据划分：定义训练集和验证集占原始数据的比例\n",
    "train_ratio = 0.75\n",
    "val_ratio = 0.2\n",
    "test_ratio = 0.05\n",
    "\n",
    "# 1. 定义YOLO的路径和数据集的路径\n",
    "yolo_datasets_path = os.path.join(\"E:\\\\\", \"datasets\")\n",
    "sar_aircraft_path = os.path.join(yolo_datasets_path, \"sar_aircraft\")\n",
    "classification_path = os.path.join(sar_aircraft_path, \"two_classification\")\n",
    "\n",
    "# 2. 在yolo的dataset中创建数据集目录，有的话直接删除，重新创建\n",
    "try:\n",
    "    # shutil.rmtree(classification_path)\n",
    "    # os.makedirs(classification_path)\n",
    "    print(\"项目目录已重新创建\")\n",
    "except FileNotFoundError:\n",
    "    os.makedirs(classification_path)\n",
    "    print(\"项目目录已创建\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7785a734-0c2a-44d0-ab3b-dfb54c495ae8",
   "metadata": {},
   "source": [
    "### 3.2 找出A330的图像的正反例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "450ce4a1-4568-42b4-a31e-60ccc5130b6a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>文件名</th>\n",
       "      <th>第一列内容</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0000001.txt</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0000001.txt</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0000002.txt</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0000002.txt</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0000002.txt</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16458</th>\n",
       "      <td>0004368.txt</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16459</th>\n",
       "      <td>0004368.txt</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16460</th>\n",
       "      <td>0004368.txt</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16461</th>\n",
       "      <td>0004368.txt</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16462</th>\n",
       "      <td>0004368.txt</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>16463 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               文件名  第一列内容\n",
       "0      0000001.txt      5\n",
       "1      0000001.txt      4\n",
       "2      0000002.txt      5\n",
       "3      0000002.txt      2\n",
       "4      0000002.txt      2\n",
       "...            ...    ...\n",
       "16458  0004368.txt      4\n",
       "16459  0004368.txt      2\n",
       "16460  0004368.txt      2\n",
       "16461  0004368.txt      2\n",
       "16462  0004368.txt      2\n",
       "\n",
       "[16463 rows x 2 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b9db5ce-17ed-4006-9deb-3f89d72632f0",
   "metadata": {},
   "source": [
    "### 3.2 第三轮 追加所有数据追加进去继续训练"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "70bc94c7-1f3c-46ae-9b1e-98094b7335f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "def getlabelsfilelist(file_path):\n",
    "    \"\"\"\n",
    "        获取labels文件列表\n",
    "    \"\"\"\n",
    "    labels_list = []\n",
    "    for root, _, files in os.walk(file_path):\n",
    "            for file in files:\n",
    "                if file.endswith('.txt'):\n",
    "                    labels_list.append(file)\n",
    "    return labels_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "8dfb10d5-b73c-4896-9b50-ce3d26fb9586",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2111, 182, 726, 3019)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 先拿到现有数据的切分\n",
    "train_labels_012_all_path = os.path.join(classification_path, \"class_012\", \"labels\", \"train\")\n",
    "train_labels_012_all = getlabelsfilelist(train_labels_012_all_path)\n",
    "test_labels_012_all_path = os.path.join(classification_path, \"class_012\", \"labels\", \"test\")\n",
    "test_labels_012_all = getlabelsfilelist(test_labels_012_all_path)\n",
    "val_labels_012_all_path = os.path.join(classification_path, \"class_012\", \"labels\", \"val\")\n",
    "val_labels_012_all = getlabelsfilelist(val_labels_012_all_path)\n",
    "\n",
    "classified_file_names = train_labels_012_all + test_labels_012_all + val_labels_012_all\n",
    "\n",
    "len(train_labels_012_all), len(test_labels_012_all), len(val_labels_012_all), len(classified_file_names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ab9d793e-fc4c-4b12-b93c-0bf91d506527",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4368\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(1349, 3019)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 算出未分类的数据集\n",
    "# 所有数据集\n",
    "all_file_names = set(data[\"文件名\"])\n",
    "print(len(all_file_names))\n",
    "# 未分类数据集\n",
    "unclassify_files = [file for file in all_file_names if file not in train_labels_012_all + test_labels_012_all + val_labels_012_all]\n",
    "len(unclassify_files), len(all_file_names) - len(unclassify_files)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7565939a-7ab4-4b54-a4ec-2037d564417e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1012.0, 270.0, 67.0)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 最后数据不多，直接暴力划分。\n",
    "train_num = round(len(unclassify_files) * 0.75, ndigits=0)\n",
    "val_num = round(len(unclassify_files) * 0.2, ndigits=0)\n",
    "test_num = round(len(unclassify_files) * 0.05, ndigits=0)\n",
    "train_num, val_num, test_num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "53db1206-2854-4b27-bf88-b5a401580493",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1012\n",
      "337\n",
      "270\n",
      "67\n"
     ]
    }
   ],
   "source": [
    "train_files_add = random.sample(unclassify_files, int(train_num))\n",
    "print(len(train_files_add))\n",
    "unclassify_files = set(unclassify_files) - set(train_files_add)\n",
    "print(len(unclassify_files))\n",
    "val_files_add = random.sample(list(unclassify_files), int(val_num))\n",
    "print(len(val_files_add))\n",
    "unclassify_files = set(unclassify_files) - set(val_files_add)\n",
    "test_files_add = list(unclassify_files)\n",
    "print(len(test_files_add))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "66b766e5-cb5f-40f6-a144-00703f920ce5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3123, 996, 249)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_labels_all = train_labels_012_all + train_files_add\n",
    "val_labels_all = val_labels_012_all + val_files_add\n",
    "test_labels_all = test_labels_012_all + test_files_add\n",
    "\n",
    "len(train_labels_all), len(val_labels_all), len(test_labels_all)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2675b9d9-76e8-4927-8965-4287abcf1559",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(list, list, list)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(train_labels_all), type(val_labels_all), type(test_labels_all)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "47537019-5e65-4661-a168-3bbe949a6de5",
   "metadata": {},
   "source": [
    "### 3.4 转换标签文件格式，从xml转换到txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "29d8699f-31c5-4ea5-b6c4-5b4cc5d3439d",
   "metadata": {},
   "outputs": [],
   "source": [
    "def xml_transfer_yolo_bak(source_file_name, object_folder, file):\n",
    "    \"\"\"\n",
    "        定义转换格式的函数\n",
    "        把xml（voc）格式转化为txt（yolo）格式\n",
    "    \"\"\"\n",
    "    tree = ElementTree.parse(source=source_file_name)\n",
    "    root = tree.getroot()\n",
    "\n",
    "    # 图像的高度和宽度\n",
    "    img_width = int(root.find(path=\"size\").find(path=\"width\").text)\n",
    "    img_height = int(root.find(path=\"size\").find(path=\"height\").text)\n",
    "\n",
    "    # 转化标注信息\n",
    "    # finaly_file_name = os.path.splitext(file)[0] + \".txt\"\n",
    "    with open(file=os.path.join(object_folder, file), mode=\"w\", encoding=\"utf8\") as f:\n",
    "        # 遍历每个目标\n",
    "        # print(finaly_file_name)\n",
    "        for obj in root.findall(path=\"object\"):\n",
    "            name = obj.find(path=\"name\").text\n",
    "            if name in [\"\", \"\", \"\"]:\n",
    "                cls_id = label2idx.get(name)\n",
    "                xmin = int(obj.find(path=\"bndbox\").find(path=\"xmin\").text)\n",
    "                ymin = int(obj.find(path=\"bndbox\").find(path=\"ymin\").text)\n",
    "                xmax = int(obj.find(path=\"bndbox\").find(path=\"xmax\").text)\n",
    "                ymax = int(obj.find(path=\"bndbox\").find(path=\"ymax\").text)\n",
    "    \n",
    "                \"\"\"\n",
    "                    开始标注转化\n",
    "                    - yolo需要的是相对坐标，也就是相对于原始图像的比例，这样当图像resize到不同\n",
    "                    尺寸时，相对坐标所标注的框位置不变，可以更好的应对不同尺寸的图像\n",
    "                \"\"\"\n",
    "                # 1. 中心点坐标\n",
    "                # print(type(xmin), type(xmax), type(img_width))\n",
    "                x_center = round(number=(xmin + xmax) / 2 / img_width, ndigits=6)\n",
    "                y_center = round(number=(ymin + ymax) / 2 / img_height, ndigits=6)\n",
    "                box_width = round(number=(xmax - xmin) / img_width, ndigits=6)\n",
    "                box_height = round(number=(ymax - ymin) / img_height, ndigits=6)\n",
    "                print(cls_id, x_center, y_center, box_width, box_height, sep=\" \", end=\"\\n\", file=f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "e40c5f3d-e54c-4acf-a746-b17ca591c50e",
   "metadata": {},
   "outputs": [],
   "source": [
    "def xml_transfer_yolo(source_file_name, object_folder, file):\n",
    "    \"\"\"\n",
    "        定义转换格式的函数\n",
    "        把xml（voc）格式转化为txt（yolo）格式\n",
    "    \"\"\"\n",
    "    tree = ElementTree.parse(source=source_file_name)\n",
    "    root = tree.getroot()\n",
    "\n",
    "    # 图像的高度和宽度\n",
    "    img_width = int(root.find(path=\"size\").find(path=\"width\").text)\n",
    "    img_height = int(root.find(path=\"size\").find(path=\"height\").text)\n",
    "\n",
    "    # 转化标注信息\n",
    "    # finaly_file_name = os.path.splitext(file)[0] + \".txt\"\n",
    "    with open(file=os.path.join(object_folder, file), mode=\"w\", encoding=\"utf8\") as f:\n",
    "        # 遍历每个目标\n",
    "        # print(finaly_file_name)\n",
    "        for obj in root.findall(path=\"object\"):\n",
    "            name = obj.find(path=\"name\").text\n",
    "            cls_id = label2idx.get(name)\n",
    "            xmin = int(obj.find(path=\"bndbox\").find(path=\"xmin\").text)\n",
    "            ymin = int(obj.find(path=\"bndbox\").find(path=\"ymin\").text)\n",
    "            xmax = int(obj.find(path=\"bndbox\").find(path=\"xmax\").text)\n",
    "            ymax = int(obj.find(path=\"bndbox\").find(path=\"ymax\").text)\n",
    "\n",
    "            \"\"\"\n",
    "                开始标注转化\n",
    "                - yolo需要的是相对坐标，也就是相对于原始图像的比例，这样当图像resize到不同\n",
    "                尺寸时，相对坐标所标注的框位置不变，可以更好的应对不同尺寸的图像\n",
    "            \"\"\"\n",
    "            # 1. 中心点坐标\n",
    "            x_center = round(number=(xmin + xmax) / 2 / img_width, ndigits=6)\n",
    "            y_center = round(number=(ymin + ymax) / 2 / img_height, ndigits=6)\n",
    "            box_width = round(number=(xmax - xmin) / img_width, ndigits=6)\n",
    "            box_height = round(number=(ymax - ymin) / img_height, ndigits=6)\n",
    "            print(cls_id, x_center, y_center, box_width, box_height, sep=\" \", end=\"\\n\", file=f)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0fae049e-2f96-47f1-b3af-817669fd45b8",
   "metadata": {},
   "source": [
    "### 3.5 复制img和label到yolo数据集目录下"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "6960fb4b-fa43-4464-b601-a364645b10f8",
   "metadata": {},
   "outputs": [],
   "source": [
    "def copy_files(files, images_path, labels_path):\n",
    "    \"\"\"\n",
    "        复制文件到yolo的数据集目录下\n",
    "            - files: 需要复制的图像文件[train_files, val_files, test_files]\n",
    "            - images_path: 需要复制到的图像路径 \n",
    "            - labels_path: 需要复制到的标签路径\n",
    "    \"\"\"\n",
    "    for file in files:\n",
    "        # 复制图像\n",
    "        shutil.copy(os.path.join(root_images_path, os.path.splitext(file)[0] + '.jpg'), images_path)\n",
    "        # 复制标签\n",
    "        label_file = os.path.splitext(file)[0] + '.xml'\n",
    "        xml_transfer_yolo(source_file_name=os.path.join(root_labels_path, label_file), object_folder=labels_path, file=file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "78626856-8bd9-4a36-a822-867fbe530230",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 创建出数据集目录结构\n",
    "# yolo需要的目录结构\n",
    "images_labels_list = [\"images\", \"labels\"]\n",
    "train_val_test_list = [\"train\", \"val\", \"test\"]\n",
    "\n",
    "# 创建各个分类的目录\n",
    "cls_path = os.path.join(classification_path, \"class_all\")\n",
    "if not os.path.exists(cls_path):\n",
    "    os.makedirs(cls_path)\n",
    "for path_0 in images_labels_list:\n",
    "    images_labels_path = os.path.join(cls_path, path_0)\n",
    "    if not os.path.exists(images_labels_path):\n",
    "        os.makedirs(images_labels_path)\n",
    "    for path_1 in train_val_test_list:\n",
    "        train_val_test_path = os.path.join(images_labels_path, path_1)\n",
    "        os.makedirs(train_val_test_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "af3ef7d5-5993-4a7f-bae8-40b747e5d668",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 训练集\n",
    "copy_files(files=train_labels_all, images_path=os.path.join(classification_path, \"class_all\", \"images\", \"train\"), labels_path=os.path.join(classification_path, \"class_all\", \"labels\", \"train\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1551e97d-43e2-4bcb-9300-df82b173c6b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 验证集\n",
    "copy_files(files=val_labels_all, images_path=os.path.join(classification_path, \"class_all\", \"images\", \"val\"), labels_path=os.path.join(classification_path, \"class_all\", \"labels\", \"val\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "18cb1675-7c69-4e8e-a82c-c21b262da069",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 训练集\n",
    "copy_files(files=test_labels_all, images_path=os.path.join(classification_path, \"class_all\", \"images\", \"test\"), labels_path=os.path.join(classification_path, \"class_all\", \"labels\", \"test\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "3cf3deeb-7c83-4c0c-b4f3-035c3e18c1c0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3123, 249, 996)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 减产生产的文件\n",
    "train_labels_all_path = os.path.join(classification_path, \"class_all\", \"labels\", \"train\")\n",
    "train_labels_all = getlabelsfilelist(train_labels_all_path)\n",
    "test_labels_all_path = os.path.join(classification_path, \"class_all\", \"labels\", \"test\")\n",
    "test_labels_all = getlabelsfilelist(test_labels_all_path)\n",
    "val_labels_all_path = os.path.join(classification_path, \"class_all\", \"labels\", \"val\")\n",
    "val_labels_all = getlabelsfilelist(val_labels_all_path)\n",
    "\n",
    "len(train_labels_all), len(test_labels_all), len(val_labels_all),"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "e05753f0-2cf3-4f71-9ae6-37dd1941ed9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3123\n",
      "996\n",
      "249\n"
     ]
    }
   ],
   "source": [
    "print(len(train_labels_all)), \n",
    "print(len(val_labels_all)), \n",
    "print(len(test_labels_all))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ebdf338e-fbdf-47d2-8a31-ca102519676a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
